package dto

import (
	"tuowei.com/app/api/models"
	"tuowei.com/common/dto"
	common "tuowei.com/common/models"
)

type SysScoreGetPageReq struct {
	dto.PaginationNew `search:"-"`
	BuyerId           int `json:"buyer_id" search:"type:exact;column:buyer_id;table:sys_score" comment:"买家id"` // 买家id
	Change            int `json:"change" search:"type:exact;column:change;table:sys_score" comment:"1积分收入或者2支出" `
}

func (m *SysScoreGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type SysScoreGeAllReq struct {
	BuyerId int `json:"buyer_id" search:"type:exact;column:buyer_id;table:sys_score" comment:"买家id"` // 买家id
}

func (m *SysScoreGeAllReq) GetNeedSearch() interface{} {
	return *m
}

type SysScoreInsertReq struct {
	BuyerId      int     `comment:"买家id" json:"buyer_id"` //买家id
	OrderNumber  string  `gorm:"type:varchar(64);not null;default:'';index;comment:订单编号" json:"order_number"`
	ScoreChange  float64 `gorm:"type:decimal(10,2);comment:积分变动" json:"score_change"`
	Change       int     `gorm:"type:int(10);not null;default:1;index;comment:1积分收入或者支出" json:"change"`
	ScoreSum     float64 `gorm:"type:decimal(10,2);comment:本次变动后的积分总额" json:"score_sum"`
	OrderType    string  `gorm:"type:varchar(64);comment:商品类型OnlineOrder，MaterialOrder,LiveOrder" json:"order_type"`
	Subject      string  `gorm:"type:varchar(64);comment:科目" json:"subject"`
	Name         string  `gorm:"type:varchar(64);comment:课程名称" json:"name"`
	Cover        string  `gorm:"type:varchar(500);comment:封面" json:"cover"`
	Introduction string  `gorm:"type:varchar(500);comment:课程简介" json:"introduction"`
	common.ControlBy
}

func (s *SysScoreInsertReq) Generate(model *models.SysScore) {
	//model.CourseId = s.CourseId
	model.BuyerId = s.BuyerId
	model.OrderNumber = s.OrderNumber
	model.ScoreChange = s.ScoreChange
	model.Change = s.Change
	model.ScoreSum = s.ScoreSum
	model.OrderType = s.OrderType
	model.Subject = s.Subject
	model.Name = s.Name
	model.Cover = s.Cover
	model.Introduction = s.Introduction
}

func (s *SysScoreInsertReq) GetId() interface{} {
	return s.BuyerId
}
